package com.uchonor.api.core.service;

import com.uchonor.olight.agent.annotation.Inject;
import com.uchonor.olight.agent.annotation.Service;

import java.util.List;

@Service
public class DataSourceMetaDataContext {
    @Inject
    private List<IDataSourceMetaDataStrategy> iDataSourceMetaDataStrategyList;
    @Inject
    private DefaultDataSourceMetaDataStrategy defaultDataSourceMetaDataStrategy;

    public IDataSourceMetaDataStrategy getDataSourceMetaDataStrategy(String jdbcUrl){
        return iDataSourceMetaDataStrategyList.stream().filter(item->item.supper(jdbcUrl)).findFirst().orElse(defaultDataSourceMetaDataStrategy);
    }
}
